﻿using NUnit.Framework;
using SUT.Validation;

namespace SUT.Fixture2
{
    public class FakeNetworkNode : INode
    {
        private readonly bool m_isAlive;

        public FakeNetworkNode(bool isAlive)
        {
            m_isAlive = isAlive;
        }


        public bool IsAlive()
        {
            return m_isAlive;
        }
    }

    [TestFixture]
    public class NetworkMonitorFixture
    {
        [Test]
        public void Check_ValidAddress_NoFailingNodes()
        {
            var monitor = new NetworkMonitor();
            monitor.Check(new FakeNetworkNode(true));
            Assert.AreEqual(0, monitor.FailingNodes);
            Assert.IsTrue(monitor.IsUpAndRunning);
        }

        [Test]
        public void Check_InvalidAddress_1FailingNodes()
        {
            var monitor = new NetworkMonitor();
            monitor.Check(new FakeNetworkNode(false));
            Assert.AreEqual(1, monitor.FailingNodes);
            Assert.IsFalse(monitor.IsUpAndRunning);
        }
    }
}
